//
//  ComHeaderView.m
//  TheRoadAD
//
//  Created by baixue on 16/8/10.
//  Copyright © 2016年 baixue. All rights reserved.
//

#import "ComHeaderView.h"
#define Title @[@"频道",@"精选"]

static int i;
@implementation ComHeaderView

-(id)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        // 创建header 轮播图
      /*  UIView *header = [[UIView alloc] init];
        header.backgroundColor = [UIColor whiteColor];
        CGRect  rect = CGRectMake(0, 0, Screen_Width, 200 * Screen_Height / 736);
        NSArray *arr = @[@"1.jpg",@"2.jpg",@"3.jpg",@"4.jpg",@"5.jpg"];
        LyScrollBanner *ScrollBanner = [LyScrollBanner LyScrollBannerWithFrame:rect
                                                                ImageNameArray:arr];
        ScrollBanner.delegate = self;
        //        ScrollBanner.isCancelAutoNextPage = YES;
        //        ScrollBanner.isCancelPageControl = YES;
        //        ScrollBanner.isCancelInfiniteBanner = YES;
        [self addSubview:ScrollBanner];
        */
        //设置header 高度
        UIView *backView = [[UIView alloc] initWithFrame:CGRectMake(0, 0 , Screen_Width, 50)];
        backView.backgroundColor = [UIColor colorWithRed:0.96 green:0.96 blue:0.96 alpha:1];
        for (i = 0; i < 2; i++) {
            
            UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
            button.frame = CGRectMake(Screen_Width/2*i, 5, Screen_Width/2, 40);
            [button setTitle:Title[i] forState:UIControlStateNormal];
            [button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
            [button setBackgroundColor:[UIColor whiteColor]];
            button.titleLabel.font = [UIFont systemFontOfSize:14];
            [button addTarget:self action:@selector(buttonClicked:) forControlEvents:UIControlEventTouchUpInside];
            button.tag = 125+i;
            [backView addSubview:button];
           
        }
        UIView *line = [[UIView alloc] initWithFrame:CGRectMake(0 , 45, Screen_Width/2, 2)];
        _line = line;
        line.backgroundColor = [UIColor colorWithRed:0.35 green:0.85 blue:0.82 alpha:1];

        UIView *lineH = [[UIView alloc] initWithFrame:CGRectMake(Screen_Width/2, 15, 1, 15)];
        lineH.backgroundColor = [UIColor colorWithRed:0.35 green:0.85 blue:0.82 alpha:1];
        [backView addSubview:lineH];
        [backView addSubview:_line];
        [self addSubview:backView];
    }
    return self;
}

-(void)buttonClicked:(UIButton *)sender{

     NSInteger tag =  sender.tag ;
    _SelectBlock(tag);

}


@end
